<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../aaa/css/font.css">
    <link rel="stylesheet" href="../aaa/css/xadmin.css">
    <script type="text/javascript" src="../aaa/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../aaa/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">

                <div class="layui-form-item">
                    <label  class="layui-form-label">
                        <span class="x-red">*</span>分销需求id:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="dis_need_id" name="dis_need_id" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                    <label class="layui-form-label">分销商:</label>
                    <div class="layui-input-inline">
                        <select name="distributorid" id="distributorid" lay-verify="required" class="layui-input">
                            <option value="">请选择分销商</option>
                            <option th:each="distributors:${distributors}"
                                    th:value="${distributors.distributorid}"
                                    th:text="${distributors.distributorname}"
                            ></option>
                        </select>
                    </div>
                    <label class="layui-form-label">商品供应商:</label>
                    <div class="layui-input-inline">
                        <select name="supId" id="supId" lay-verify="required" class="layui-input">
                            <option value="">请选择商品供应商</option>
                            <option th:each="suppliers:${suppliers}"
                                    th:value="${suppliers.supId}"
                                    th:text="${suppliers.supName}"
                            ></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">商品:</label>
                    <div class="layui-input-inline">
                        <select name="commodityid" id="commodityid"  lay-verify="required" class="layui-input">
                            <option value="">请选择商品</option>
                            <option th:each="commodities:${commodities}"
                                    th:value="${commodities.commodityid}"
                                    th:text="${commodities.commodityname}"
                            ></option>
                        </select>
                    </div>
                    <label class="layui-form-label">包装类型:</label>
                    <div class="layui-input-inline">
                        <select name="Bcategoryid" id="Bcategoryid" lay-verify="required" class="layui-input">
                            <option value="">请选择包装类别</option>
                            <option th:each="Bcategory:${bcategory}"
                                    th:value="${Bcategory.Bcategoryid}"
                                    th:text="${Bcategory.Bcategoryname}"
                            ></option>
                        </select>
                    </div>
                    <label class="layui-form-label">包装供应商:</label>
                    <div class="layui-input-inline" >
                        <select name="BsupId" id="BsupId" lay-verify="required" class="layui-input">
                            <option value="">请选择包装供应商</option>
                            <option th:each="bsuppliers:${bsuppliers}"
                                    th:value="${bsuppliers.BsupId}"
                                    th:text="${bsuppliers.BsupName}"
                            ></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">
                        <span class="x-red">*</span>物流单号:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="logparticularsid" name="logparticularsid" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                    <label class="layui-form-label">运输方式:</label>
                    <div class="layui-input-inline">
                        <select name="logmodeid" id="logmodeid" lay-verify="required" class="layui-input">
                            <option value="">请选择运输方式</option>
                            <option th:each="logmodes:${logmodes}"
                                    th:value="${logmodes.logmodeid}"
                                    th:text="${logmodes.logmodename}"
                            ></option>
                        </select>
                    </div>
                    <label class="layui-form-label">物流公司:</label>
                    <div class="layui-input-inline">
                        <select name="logId" id="logId" lay-verify="required" class="layui-input">
                            <option value="">请选择物流公司</option>
                            <option th:each="logistics:${logistics}"
                                    th:value="${logistics.logId}"
                                    th:text="${logistics.logname}"
                            ></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">包装名:</label>
                    <div class="layui-input-inline" >
                        <select name="needId" id="needId" lay-verify="required" class="layui-input">
                            <option value="">请选择包装名</option>
                            <option th:each="need:${needs}"
                                    th:value="${need.needId}"
                                    th:text="${need.needName}"
                            ></option>
                        </select>
                    </div>
                    <label  class="layui-form-label">
                        <span class="x-red">*</span>商品数量:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="Samnumber" name="Samnumber" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                    <label  class="layui-form-label">
                        <span class="x-red">*</span>定金:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="advance" name="advance" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label  class="layui-form-label">
                        <span class="x-red">*</span>日期:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="test1" name="birth" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                    <label  class="layui-form-label">
                        <span class="x-red">*</span>包装数量:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="satypenumber" name="satypenumber" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                    <label class="layui-form-label">审核状态:</label>
                    <div class="layui-input-inline" >
                        <!--                        style="width: 180px"-->
                        <!--                        <select name="statusid" id="statusid" style="width: 165px" lay-verify="required" class="layui-input">-->
                        <!--                            <option value="">请选择审核状态</option>-->
                        <!--                            <option th:each="status1s:${status1s}"-->
                        <!--                                    th:value="${status1s.statusid}"-->
                        <!--                                    th:text="${status1s.statusname}"-->
                        <!--                            ></option>-->
                        <!--                        </select><br>-->
                        <input type="radio" name="statusid" value="2" title="已审核" disabled>
                        <input type="radio" name="statusid" value="1" title="未审核" checked disabled>
                    </div>
                </div>
            <div class="layui-form-item">
                <center>
                    <button  class="layui-btn" lay-filter="add" lay-submit="" >
                        增加
                    </button>
                </center>
            </div>
        </form>



        <table class="layui-table layui-form">
            <thead>
            <tr>
                <th>编号</th>
                <th>需求项目名</th>
                <th>样板包装图片</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="list:${needs}">
                <td th:text="${list.needId}"></td>
                <td th:text="${list.needName}"></td>
                <td>
                    <img th:src="@{${list.needimg}}" width="80" height="80"/></td>
            </tr>
            </tbody>
        </table>

    </div>
</div>
<script src="/static/lib/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layer','jquery'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            //监听提交
            form.on('submit(add)',
                function(data) {
                    console.log(data.field);
                    var datas=data.field;
                    if (datas.status=="on"){
                        datas.status=0;//正常状态
                    }else {
                        datas.status=1;
                    }
                    $.ajax({
                        url: "/dis_need/Dis_needAdd",
                        type: "POST",
                        data:datas,
                        success: function (result) {
                            if (result.code==200){
                                layer.msg("添加失败");
                            }
                            else {
                                layer.msg("添加成功",{
                                    icon: 6,
                                    time:500
                                },function() {
                                    parent.window.location.reload();//重新页面
                                    // 获得frame索引
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                });
                            }
                        }
                    });
                    return false;
                });

            $(function() {
                //（YB + 年月日 + 四位随机数）
                var myDate = new Date;
                var year = myDate.getFullYear(); //获取当前年
                var mon = myDate.getMonth() + 1; //获取当前月
                // var date = myDate.getDate(); //获取当前日
                // if (date<10){
                //     date = "0"+date;
                // }
                var x = 99;
                var y = 999;
                var rand = parseInt(Math.random()*(x-y+1)+y);
                $("input[name='logparticularsid']").val("WL"+year+""+mon+""+""+rand);
                $("input[name='dis_need_id']").val("XQ"+year+""+mon+""+""+rand);

                // $("input[name='date_of_order']").val(year+"-"+mon+"-"+date);
            });
        });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#test1',
            trigger: 'click'//指定元素
        });
    });


</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
